import { request } from '../request';

/** get list */
export function userList(params: Api.SystemManage.UserSearchParams) {
  return request<Api.SystemManage.UserList>({
    url: '/user/list',
    method: 'post',
    data: params
  });
}

/** save */
export function userSave(params: Api.SystemManage.UserSaveParams) {
  return request<boolean>({
    url: '/user/add',
    method: 'post',
    data: params
  });
}

/** update */
export function userUpdate(params: Api.SystemManage.UserUpdateParams & { roleIds: Array<string> }) {
  return request<boolean>({
    url: '/user/update',
    method: 'post',
    data: params
  });
}

/** get */
export function userGet(params: { id: string }) {
  return request<Api.SystemManage.User & { roles: Api.SystemManage.AllRole; roleIds: string[] }>({
    url: '/user/get',
    method: 'post',
    data: params
  });
}

/** del */
export function userDel(params: { id: string }) {
  return request<boolean>({
    url: '/user/del',
    method: 'post',
    data: params
  });
}

/** reset */
export function userReset(params: { id: string }) {
  return request<boolean>({
    url: '/user/reset',
    method: 'post',
    data: params
  });
}

/** delBatch */
export function userDelBatch(params: { ids: Array<string> }) {
  return request<Api.SystemManage.User>({
    url: '/user/delBatch',
    method: 'post',
    data: params
  });
}

export function userRoleList() {
  return request<Api.SystemManage.SelectVO[]>({
    url: '/user/roleList',
    method: 'get'
  });
}
